//参数说明：list.DPknapsack(容量，重量，[每件物品的件数]，价值，[规则]）

class Obj{
	name,weight,value;
	Obj(name,weight,value){
	}
}
//====================================================================================================

//01背包
list=[new Obj("a",2,6.0),new Obj("b",2,3.0),new Obj("c",6,5.0),new Obj("d",5,4.0),new Obj("e",4,6.0)];
println("01背包问题:\n"+list.dpKnapsack(10,list.weight,1,list.value));

//完全背包
list=[new Obj("a",2,6.0),new Obj("b",2,3.0),new Obj("c",6,5.0),new Obj("d",5,4.0),new Obj("e",4,6.0)];
println("完全背包问题:\n"+list.dpKnapsack(10,list.weight,list.value));


//多重背包
list=[new Obj("a",12,4.0),new Obj("b",2,2.0),new Obj("c",1,1.0),new Obj("d",4,10.0),new Obj("e",1,2.0)];
println("多重背包问题:\n"+list.dpKnapsack(15,list.weight,[1,7,12,3,1],list.value));


//混合背包
list=[new Obj("a",12,4.0),new Obj("b",2,2.0),new Obj("c",1,1.0),new Obj("d",4,10.0),new Obj("e",1,2.0)];
println("多重背包问题:\n"+list.dpKnapsack(15,list.weight,[1,7,12,3,-1],list.value));



